package offer;

public class Solution48 {
    public int lengthOfLongestSubstring(String s) {
        int res = 0, start = 0;
        int[] index = new int[128];
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            start = Math.max(start, index[c]);
            res = Math.max(res, i + 1 - start);
            index[c] = i + 1;
        }
        return res;
    }
}
